package com.yic.module.mes.dal.mysql.itemproduce;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.mes.dal.dataobject.itemproduce.ItemProduceDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.mes.controller.admin.itemproduce.vo.*;

/**
 * 产品生产信息 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ItemProduceMapper extends BaseMapperX<ItemProduceDO> {

    default PageResult<ItemProduceDO> selectPage(ItemProducePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ItemProduceDO>()
                .eqIfPresent(ItemProduceDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ItemProduceDO::getWorkshopId, reqVO.getWorkshopId())
                .eqIfPresent(ItemProduceDO::getItemId, reqVO.getItemId())
                .eqIfPresent(ItemProduceDO::getQualityType, reqVO.getQualityType())
                .eqIfPresent(ItemProduceDO::getPickingType, reqVO.getPickingType())
                .betweenIfPresent(ItemProduceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ItemProduceDO::getId));
    }

    default List<ItemProduceDO> selectList(ItemProduceExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ItemProduceDO>()
                .eqIfPresent(ItemProduceDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ItemProduceDO::getWorkshopId, reqVO.getWorkshopId())
                .eqIfPresent(ItemProduceDO::getItemId, reqVO.getItemId())
                .eqIfPresent(ItemProduceDO::getQualityType, reqVO.getQualityType())
                .eqIfPresent(ItemProduceDO::getPickingType, reqVO.getPickingType())
                .betweenIfPresent(ItemProduceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ItemProduceDO::getId));
    }

    default ItemProduceDO selectOne(Long itemId, Long factoryId) {
        return selectOne(new LambdaQueryWrapperX<ItemProduceDO>()
                .eq(ItemProduceDO::getItemId, itemId)
                .eq(ItemProduceDO::getFactoryId, factoryId));
    }

    default ItemProduceDO selectByFactoryAndItem(Long factoryId, Long itemId) {
        return selectOne(new LambdaQueryWrapperX<ItemProduceDO>()
                .eq(ItemProduceDO::getItemId, itemId)
                .eq(ItemProduceDO::getFactoryId, factoryId));
    }
}
